Hello altogether,
I hope anybody can help me. I've to write a dxl script for our DOORS (9.6.0.1) which has to be executed from the context menu in the module explorer; so I've added a script in the explorerTreePopFiles folder which creates the corresponding menu item for me. That works fine, but I realized a problem: The purpose of the script is to create a statistic for the "current/selected" project, so the starting point in the executed script is to get the current project.
string g_strProjectName = null;
string g_strProjectRootName = null;
string g_strProjectRootPath = null;
void Start()
{
// Pre-Check
Project pCurrentProject = current Project;
g_strProjectName = name(pCurrentProject);
g_strProjectRootName = rootName_(pCurrentProject);
g_strProjectRootPath = g_strProjectRootName [0:length(g_strProjectRootName) - ((length (g_strProjectName))+2)];
print "Creating statistic for the project '" g_strProjectName "', located at '" (("" == g_strProjectRootPath) ? "<ROOT>" : g_strProjectRootPath) "'\n";
// CreateStatistic()
}
Start()
This works fine if I use the left mouse button first (to select the folder/ project) but it gives me the "wrong" info if I select one item and then use another item for the right click (context menu).
The original DOORS menu contains two menu items ("New" and "Properties") which are working correctly (e.g. select "Project A" with the left mouse and then press the right mouse on "Project B" and call "Properties" --> Properties of "Project B" will be displayed while "Project A" remains active/selected. If my script will be executed with selected "Project A" and "context menu selected" "Project B" it prints the information of "Project A", not "Project B".
"current Project" as well as "getSelectedItem()" seems to be the wrong functions and something like "hasFocus" doesn't exist for the module explorer...
Has anybody an idea, how I can get the "context menu target"?
Cheers,
Michael
MichaelBrockhaus - Mon Jul 24 06:45:55 EDT 2017 |
Re: Get focused item in module explorer This won't help you too much, but the same issue exists with any treeView in DXL. If you create a treeView (like the dbexplorer) and attach a context menu to it and rightclick an entry the value of get(dbeTree) is still the previously selected entry. In such a case you'd need to use the (undocumented) "string getRightClicked(dbeTreeView)" function to get the actual target of the rightclick.
Sadly this won't help you in your case, as you don't have a handle to the treeView in question, but I assume it is the same issue here. |
Re: Get focused item in module explorer O.Wilkop - Wed Jul 26 04:00:11 EDT 2017 This won't help you too much, but the same issue exists with any treeView in DXL. If you create a treeView (like the dbexplorer) and attach a context menu to it and rightclick an entry the value of get(dbeTree) is still the previously selected entry. In such a case you'd need to use the (undocumented) "string getRightClicked(dbeTreeView)" function to get the actual target of the rightclick.
Sadly this won't help you in your case, as you don't have a handle to the treeView in question, but I assume it is the same issue here. There is actually an Item function: Item I = getTreeRightClickedItem() print (fullName I) The DB variable of the explorer is "dbExpTree" string s = getRightClicked(dbExpTree) print s Regards, Mathias |
Re: Get focused item in module explorer Mathias Mamsch - Wed Jul 26 07:16:32 EDT 2017 There is actually an Item function: Item I = getTreeRightClickedItem() print (fullName I) The DB variable of the explorer is "dbExpTree" string s = getRightClicked(dbExpTree) print s Regards, Mathias
Oh my god... I love these undocumented functions Matthias, thank you very, vey much. This is exactly what I was looking for. And it works absolutely perfect! |
Re: Get focused item in module explorer Mathias Mamsch - Wed Jul 26 07:16:32 EDT 2017 There is actually an Item function: Item I = getTreeRightClickedItem() print (fullName I) The DB variable of the explorer is "dbExpTree" string s = getRightClicked(dbExpTree) print s Regards, Mathias Hi Mathias, that's very good to know, but is there an equivalent for the Module list view in the explorer window? With which I could add context menu elements for Modules? Cheers, Peter |
Re: Get focused item in module explorer Peter_Albert - Fri May 17 07:27:13 EDT 2019 Hi Mathias, that's very good to know, but is there an equivalent for the Module list view in the explorer window? With which I could add context menu elements for Modules? Cheers, Peter Isnt this what the whole config folders are for? explorerListPopupFiles explorerTreePopupFiles explorerAddins formalPopupFiles linkPopupFiles etc... Regards, Mathias |
Re: Get focused item in module explorer Mathias Mamsch - Fri May 17 07:41:50 EDT 2019 Isnt this what the whole config folders are for? explorerListPopupFiles explorerTreePopupFiles explorerAddins formalPopupFiles linkPopupFiles etc... Regards, Mathias Maybe I'm not seeing the obvious here - I can place a file in explorerListPopupFiles and specify a DXL file to be executed, but how does that DXL file know for which Module it has been called?
Best regards, Peter |
Re: Get focused item in module explorer Peter_Albert - Fri May 17 08:05:46 EDT 2019 Maybe I'm not seeing the obvious here - I can place a file in explorerListPopupFiles and specify a DXL file to be executed, but how does that DXL file know for which Module it has been called?
Best regards, Peter Well that is exactly the topic of this post. It should be possible to get the item on the treeview via: getTreeRightClickedItem() and the item on the listview getSelectedItem() for the listview. So you should be able to place your menu scripts in there to generate context menu items without knowing the DBEs ... I did not try it for a long time though .... Regards, Mathias |
Re: Get focused item in module explorer Mathias Mamsch - Fri May 17 09:06:04 EDT 2019 Well that is exactly the topic of this post. It should be possible to get the item on the treeview via: getTreeRightClickedItem() and the item on the listview getSelectedItem() for the listview. So you should be able to place your menu scripts in there to generate context menu items without knowing the DBEs ... I did not try it for a long time though .... Regards, Mathias getSelectedItem() is what I was missing :-) Best regards and many thanks for the quick replies, Peter |